home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Compilers⁄Interps / GCC-2.3.3r12 / Tests / testlib.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-17  |  589 b   |  42 lines  |  [TEXT/MPS ]

  1. /* Testing library. */
  2.  
  3. #include <stdio.h>
  4.  
  5. #include "testlib.h"
  6.  
  7. int numtests = 0;
  8.  
  9. int numerrs = 0;
  10.  
  11. char *curtestfile = "???";
  12.  
  13. void
  14. itesteq(long line, long n1, long n2)
  15. {
  16.     char buf[100];
  17.  
  18.     if (n1 != n2) {
  19.         sprintf(buf, ": %d != %d", n1, n2);
  20.         errmsg(line, buf);
  21.     }
  22.     ++numtests;
  23. }
  24.  
  25. void
  26. errmsg(long line, const char *msg)
  27. {
  28.     printf("File \"%s\"; Line %d ### ERROR %s \n", curtestfile, line, msg);
  29.     fflush(stdout);
  30.     ++numerrs;
  31. }
  32.  
  33. void
  34. summary()
  35. {
  36.     if (numerrs > 0) {
  37.         printf("Failed %d of %d tests.\n", numerrs, numtests);
  38.     } else {
  39.         printf("Passed all %d tests.\n", numtests);
  40.     }
  41. }
  42.